package com.fz.us.admin.company.service;

import com.fz.us.admin.company.bean.EnumManage;
import com.fz.us.admin.company.entity.Admin;
import com.fz.us.admin.base.bean.BaseEnumManager;
import com.fz.us.admin.base.bean.Result;
import com.fz.us.admin.base.bean.search.order.Order;
import com.fz.us.admin.base.bean.search.page.PagePaging;
import com.fz.us.admin.base.bean.search.result.SearchResultList;
import com.fz.us.admin.base.bean.search.result.SearchResultPaging;
import com.fz.us.admin.base.bean.search.rule.Rule;
import com.fz.us.admin.base.service.BaseService;
import com.fz.us.admin.company.entity.Company;
import com.fz.us.admin.company.entity.User;

import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

/**
 * Service接口 - 用户
 * ============================================================================
 * 版权所有 2016 。
 *
 * @author fallenpanda
 * @version 1.0 2016-08-02 。
 * ============================================================================
 */
public interface UserService extends BaseService<User, String> {

    /**
     * 通过adminId得到
     *
     * @param adminId 用户帐号Id
     *
     * @return Users
     */
    public User getUserByAdminId(String adminId);

    /**
     * 根据当前登录人查找公司
     * @return
     */
    public Company getCompanyByUser();
    public Company getCompanyByUser(User creater);
    /**
     * 获取登录人信息
     * @return
     */
    public User getLoginInfo();

    /**
     * 获取公司下的所有用户列表
     *
     * @param company 企业
     * @return
     */
    public List<User> getAllUsers(Company company);

    /**
     * 获取公司下的所有用户列表
     *
     * @param company 企业
     * @return
     */
    public List<User> getAllUsers(Company company, BaseEnumManager.StateEnum... states);

    /**
     * 创建用户
     *
     * @param name
     * @param adminId
     * @return
     */
    public User createUser(String name, String adminId);

    /**
     * 创建企业用户
     *
     * @param name
     * @param adminId
     * @param company
     * @return
     */
    public User createUser(String name, String adminId, Company company);

    /**
     * 删除用户
     *
     * @param user
     *
     * @return
     */
    public void deleteUser(User user);

    /**
     * 分页 企业下用户
     *
     * @param page
     * @param order
     * @param company
     * @return
     */
    public SearchResultPaging pagingCompanyMember(PagePaging page, List<Rule> rules, Order order, Company company, BaseEnumManager.StateEnum... states);

    /**
     * 列表 企业下用户
     *
     * @param order
     * @param company
     * @return
     */
    public SearchResultList listCompanyMember(List<Rule> rules, Order order, Company company, BaseEnumManager.StateEnum... states);

    /**
     * 校验登录账号
     *
     * @param username
     * @return
     */
    public Result validateAccount(String username);

    /**
     * 校验用户密码
     *
     * @param user
     * @param password
     * @return
     */
    public Result validPassword(User user, String password);

    /**
     * 重置用户密码
     *
     * @param user
     * @param member
     * @param newPassword
     * @return
     */
    public Result resetPasswordByRoleAdmin(User user, User member, String newPassword);

    /**
     * 修改用户密码
     *
     * @param user
     * @param password
     * @param newPassword
     * @return
     */
    public Result updatePasswordByPassword(User user, String password, String newPassword);

    /**
     * 新建企业成员
     *
     * @param username
     * @param password
     * @param name
     * @param company
     * @return
     */
    public Result createMember(String username, String password, String name, Company company);

    /**
     * 列表 Map
     *
     * @param user
     * @return
     */
    public Map<String, Object> getMemberListMap(User user);

    public String getMpAccount(User user, String openId);

    /**
     * @param name
     * @return
     */
    public String openId(String name);

    /**
     * @param user
     * @return
     */
    public String openId(User user);

    /**
     * 关联账户（微信）验证用户名和密码，通过Shiro来实现的Login
     * @param httpServletResponse
     * @param admin
     * @param openId
     * @return
     */
    public  Result linkUser(HttpServletResponse httpServletResponse, Admin admin, String openId);

    /**
     * 通过手机号查找用户
     *
     * @param mobile 手机号
     * @return Users
     */
    public User getUserByMobile(String mobile);

    /**
     * 判断是否微信登录
     * @param openId
     * @return
     */
    public boolean isWxUsers(String openId);

    /**
     * 发送短消息验证
     * @param username
     * @param passwordForget
     * @return
     */
    public Result sendAuthCode(String username, EnumManage.AuthCodeEnum passwordForget, int experience, User user);



}
